//
//  UserDefinedCellForSubViewOfSearchPartsInventory.m
//  HondaPro_2
//
//  Created by Eric on 13-6-19.
//  Copyright (c) 2013年 glendale. All rights reserved.
//

#import "UserDefinedCellForSubViewOfSearchPartsInventory.h"

@interface UserDefinedCellForSubViewOfSearchPartsInventory ()

//创建控件
-(void)initLabelsOnCell;

@end

@implementation UserDefinedCellForSubViewOfSearchPartsInventory

@synthesize arrForAllKeys = _arrForAllKeys;
@synthesize dicForAllLabels = _dicForAllLabels;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        
        [self initLabelsOnCell];
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

#pragma mark - 创建控件

-(void)initLabelsOnCell
{
    self.arrForAllKeys = [NSArray arrayWithObjects:
                     @"PART_CODE",
                     @"PART_CHINA_NAME",
                     @"PART_ENGLISH_NAME",
                     @"CAR_TYPE_ID",
                     @"UNITPRICE",
                     @"PART_STORAGE_QTY",
                     @"AVAILBLE_QTY", nil];
    
    NSDictionary *dicForAllLabelsRect = [NSDictionary dictionaryWithObjectsAndKeys:
                                         [NSValue valueWithCGRect:CGRectMake(0, 0, 134, 50)],@"PART_CODE",
                                         [NSValue valueWithCGRect:CGRectMake(135, 0, 134, 50)],@"PART_CHINA_NAME",
                                         [NSValue valueWithCGRect:CGRectMake(270, 0, 134, 50)],@"PART_ENGLISH_NAME",
                                         [NSValue valueWithCGRect:CGRectMake(405, 0, 134, 50)],@"CAR_TYPE_ID",
                                         [NSValue valueWithCGRect:CGRectMake(540, 0, 134, 50)],@"UNITPRICE",
                                         [NSValue valueWithCGRect:CGRectMake(675, 0, 134, 50)],@"PART_STORAGE_QTY",
                                         [NSValue valueWithCGRect:CGRectMake(810, 0, 128, 50)],@"AVAILBLE_QTY",nil];
    
    self.dicForAllLabels = [NSMutableDictionary dictionaryWithCapacity:[_arrForAllKeys count]];
    
    for (int i = 0; i<[_arrForAllKeys count]; i++)
    {
        UILabel *lbl = [[UILabel alloc] initWithFrame:[[dicForAllLabelsRect objectForKey:[_arrForAllKeys objectAtIndex:i]] CGRectValue]];
        lbl.backgroundColor = [UIColor clearColor];
        lbl.font = [UIFont systemFontOfSize:13];
        lbl.textColor = [UIColor grayColor];
        lbl.numberOfLines = 2;
        [self.contentView addSubview:lbl];
        
        [self.dicForAllLabels setValue:lbl forKey:[_arrForAllKeys objectAtIndex:i]];
    }
}

@end
